package com.ocr.demo;

import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Random;

public class RandomStringExample {
    public static void main(String[] args) {
        int length = 10; // 生成的字符串长度

        String characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
        Random random = new Random();
        HashSet<String> activationCodes = new HashSet<>();
        for (int i = 0; i < 30 * 500 * 100; i++) {
            StringBuilder randomString = new StringBuilder();
            for (int j = 0; j < length; j++) {
                int index = random.nextInt(characters.length());
                char randomChar = characters.charAt(index);
                randomString.append(randomChar);
            }
            activationCodes.add(randomString.toString());
            if (activationCodes.size() > 31 * 500) {
                break;
            }
        }

        List<String> allcdks = new ArrayList<>();
        for (String activationCode : activationCodes) {
            allcdks.add(activationCode);
        }
        int total = 0;
        String[] tiles = {"至尊冠名奖励","豪华冠名奖励","每日累充10元","每日累充30元","每日累充50元","每日累充100元","每日累充200元","每日累充500元","每日累充1000元","每日累充2000元","每日累充5000元","每日累充10000元","终身累充10元","终身累充30元","终身累充50元","终身累充100元","终身累充300元","终身累充500元","终身累充1000元","终身累充2000元","终身累充5000元","终身累充10000元","终身累充15000元","终身累充20000元"};
        for (int j = 0; j < tiles.length; j++) {
            List<String> cdks =new ArrayList<>();
            for (int num = 0; num < 501; num++) {
                int reward = 991007 + j;
                cdks.add(allcdks.get(total));
                System.out.println("[\"" + allcdks.get(total) + "\"] = { type = 2, reward = " + reward + ", sever = { 1, 999, }, people = 1, },");
                total++;
            }
            writer(tiles[j],cdks);
        }

    }

    public static void writer(String titel,List<String> cdks) {
        String filename = titel+".txt"; // 文件名

        try {
            FileWriter fileWriter = new FileWriter(filename);

            // 写入文件内容
            for (String cdk:cdks
                 ) {
                fileWriter.write(cdk+"\n");
            }
            // 关闭文件写入器
            fileWriter.close();
          //  System.out.println("成功生成txt文件：" + filename);
        } catch (IOException e) {
           // System.out.println("生成txt文件时出现错误：" + e.getMessage());
        }
    }
}
